{{ define "pkg-detail-actions" }}
  <div class="dropdown d-inline">
    <button
      class="btn btn-sm btn-primary dropdown-toggle"
      type="button"
      data-bs-toggle="dropdown"
      aria-expanded="false">
      Actions
    </button>
    <ul class="dropdown-menu">
      {{ if .Pkg.Spec.Suspend }}
        <li>
          <button
            class="dropdown-item"
            hx-post="{{ .PackageHref }}/resume"
            {{ if .GitopsMode }}
              data-bs-toggle="modal" data-bs-target="#modal-container"
            {{ end }}>
            <i class="bi bi-play-circle"></i>
            Resume
          </button>
        </li>
      {{ else }}
        <li>
          <button
            class="dropdown-item"
            hx-post="{{ .PackageHref }}/suspend"
            {{ if .GitopsMode }}
              data-bs-toggle="modal" data-bs-target="#modal-container"
            {{ end }}>
            <i class="bi bi-pause-circle"></i>
            Suspend
          </button>
        </li>
      {{ end }}
      <li>
        <button
          class="dropdown-item text-danger"
          hx-get="{{ .PackageHref }}/uninstall"
          hx-target="#modal-container"
          hx-swap="innerHTML"
          hx-select="#pkg-uninstall-modal"
          data-bs-toggle="modal"
          data-bs-target="#modal-container">
          <i class="bi bi-trash"></i>
          Uninstall
        </button>
      </li>
    </ul>
  </div>
{{ end }}

{{ define "pkg-detail-btns" }}
  <span id="{{ .ContainerId }}" hx-swap="none">
    {{ if ne .Status nil }}
      {{ if not .Pkg.DeletionTimestamp.IsZero }}
        <button type="button" class="btn btn-primary btn-sm fw-medium" disabled>Uninstalling</button>
      {{ else if eq .Status.Status "Pending" }}
        <button type="button" class="btn btn-primary btn-sm fw-medium" disabled>Pending</button>
      {{ else if eq .Status.Status "Failed" }}
        <a class="btn btn-danger btn-sm pe-none">
          <span>Installation Failed</span>
        </a>
        {{ template "pkg-detail-actions" . }}
      {{ else if and .Manifest .Manifest.Entrypoints }}
        <button
          class="btn btn-success btn-sm"
          hx-post="{{ .PackageHref }}/open"
          hx-swap="none"
          name="packageName"
          value="{{ .PackageName }}">
          <i class="bi bi-box-arrow-up-right"></i>
          <span>Open</span>
        </button>
        {{ template "pkg-detail-actions" . }}
      {{ else }}
        <a class="btn btn-success btn-sm pe-none">
          <i class="bi bi-check-lg"></i>
          <span>Installed</span>
        </a>
        {{ template "pkg-detail-actions" . }}
      {{ end }}
    {{ end }}
  </span>
{{ end }}
